import React from 'react'
import store from '../../redux/store'
import { changeCheckAction, deltaskAction } from '../../redux/actions'
export default function Index(props) {
  const changeCheck = (e, id) => {
    store.dispatch(changeCheckAction({ checked: e.target.checked, id }))
    console.log(store.getState().todo.list)
  }
  const deltask = (id) => {
    store.dispatch(deltaskAction(id));
  }
  return (
    <div>
      <li ><input onChange={(e) => { changeCheck(e, props.id) }} checked={props.done} type="checkbox" />  <span style={{ textDecoration: props.done ? "line-through" : '' }}>{props.val}</span>  <button onClick={() => { deltask(props.id) }} className='del'>删除</button></li>
    </div>
  )
}
